<template>
  <HomePanel :titleName="title.titleName" :titleSpan="title.titleSpan">
    <template #contain>
      <div>
        <ul class="goods-list">
          <li v-for="item in NewList" :key="item.id">
            <RouterLink :to="`/detail/${item.id}`">
              <img v-img-lazy="item.picture" alt=""  >
              <p class="name">{{ item.name }}</p>
              <p class="price">&yen;{{ item.price }}</p>
            </RouterLink>
          </li>
        </ul>
      </div>
    </template>
  </HomePanel>

</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import HomePanel from './HomePanel.vue'
import { findNewAPI } from '@/apis/home.js'

import { useIntersectionObserver } from '@vueuse/core'
import { shallowRef, useTemplateRef } from 'vue'


let title = reactive({
  titleName: '新鲜好物',
  titleSpan: '好多商品'
})
let NewList = ref([])
const findNew = async () => {
  const res = await findNewAPI()
  NewList.value = res.result
}
onMounted(() => {
  findNew()
})
</script>

<style lang="scss">
.goods-list {
  display: flex;
  justify-content: space-around;
  height: 406px;

  li {
    width: 206px;
    height: 206px;
    transition: all 0.5s;

    &:hover {
      transform: translate3d(0, -3px, 0);
      box-shadow: 0 3px 8pxrgb(0 0 0 / 20%);
    }

    img {
      width: 306px;
      height: 306px;
    }

    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }

    .price {
      color: $priceColor;
    }
  }
}
</style>